/*
 * ChatGameComponent.fx
 *
 * Created on Apr 26, 2009, 8:22:19 PM
 */

package com.dg.gaming.client.fx.gui;




import javafx.ext.swing.SwingButton;
import javafx.ext.swing.SwingTextField;
import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.Node;

/**
 * @author dito
 */

public class ChatComponent extends CustomNode{
    var messageText = DGTextArea {}
    var inputText: SwingTextField = SwingTextField {
        columns:10
        text: ""
        editable: true
};

var sendButton: SwingButton = SwingButton {
    text: "talk!"
    action: function() {
        messageText.send (inputText.text);
        inputText.text = "";
    }
    onKeyTyped: function( e: KeyEvent ):Void {
        if (e.code == KeyCode.VK_ENTER) {
            messageText.send (inputText.text);
        inputText.text = "";
        }

    }
}

    var group = Group {

        content: [ HBox {
                    spacing: 10
                     content: [
                VBox {
                    spacing: 10
                    content: [
                        HBox {
                            spacing: 10
                            content: [
                                inputText
                                sendButton
                            ]
                        }
                        messageText

                    ]
                }

            ]

            }
        ]
    }
     public override  function create():Node {
        return group;
    }
}
